package springboot.service.impl;

import org.springframework.stereotype.Service;
import springboot.Tools.time;
import springboot.dao.ClientGroupByDayDataDao;
import springboot.doMain.ClientGroupByDayData;
import springboot.service.ClientGroupByDayDataService;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * wxWork
 * springboot.service.impl
 * Created by Blue on 2021/9/8.
 */
@Service
public class ClientGroupByDayDataServiceImpl implements ClientGroupByDayDataService {
	
	final
	ClientGroupByDayDataDao clientGroupByDayDataDao;
	
	public ClientGroupByDayDataServiceImpl(ClientGroupByDayDataDao clientGroupByDayDataDao) {
		this.clientGroupByDayDataDao = clientGroupByDayDataDao;
	}
	
	@Override
	public int deleteByPrimaryKey(Long dataId) {
		return clientGroupByDayDataDao.deleteByPrimaryKey(dataId);
	}
	
	@Override
	public int insert(ClientGroupByDayData record) {
		return clientGroupByDayDataDao.insert(record);
	}
	
	@Override
	public int insertSelective(ClientGroupByDayData record) {
		return clientGroupByDayDataDao.insertSelective(record);
	}
	
	@Override
	public List<ClientGroupByDayData> selClientGroupByDayData(long start, long end) {
		List<ClientGroupByDayData> clientGroupByDayData = clientGroupByDayDataDao.selClientGroupByDayData(start, end);
		/*遍历修改，把时间戳改为格式化后的时间并赋值*/
		clientGroupByDayData.forEach(clientGroupByDayData1 ->
				clientGroupByDayData1.setDateString(
						time.dateFormat(new Date(clientGroupByDayData1.getDate() * 1000), 2)));
		return clientGroupByDayData;
	}
	
	@Override
	public Map<String, String> selBigGroupTotal(long start) {
		return clientGroupByDayDataDao.selBigGroupTotal(start, start + 24 * 3600);
	}
	
	
	@Override
	public int updateByPrimaryKeySelective(ClientGroupByDayData record) {
		return clientGroupByDayDataDao.updateByPrimaryKeySelective(record);
	}
	
	@Override
	public int updateByPrimaryKey(ClientGroupByDayData record) {
		return clientGroupByDayDataDao.updateByPrimaryKey(record);
	}
}
